<%@ include file="../common/IncludeTop.jsp"%>

<div id="Catalog">
	<form action="saveAccount">
		<%--	<stripes:form--%>
		<%--	beanclass="org.mybatis.jpetstore.web.actions.AccountActionBean"--%>
		<%--	focus="">--%>

		<h3>User Information</h3>

		<table>
			<tr>
				<td>User ID:</td>
				<td>${account.username}</td>
			</tr>
			<tr>
				<td>New password:</td>
				<td><input type="text" name="password" id = "psw1"/></td>
			</tr>
			<tr>
				<td>Repeat password:</td>
				<td><input type="text" name="repeatedPassword" id = "psw2" onblur="checkPassword();"/><br>
					<span id="isCorrectInfo"></span>
				</td>
			</tr>
		</table>
		<script type="text/javascript" src="${pageContext.request.contextPath}ajax.js"></script>
		<script type="text/javascript">
			var xhr = new XMLHttpRequest();
			function checkPassword() {
				var psw1 = document.getElementById('psw1').value;
				var psw2 = document.getElementById('psw2').value;
				var msg = document.getElementById('isCorrectInfo');
				if(psw1==psw2){
					msg.classList.add('okmsg');
					msg.innerText = 'correct';
				}
				else {
					msg.classList.add('errormsg');
					msg.innerText = 'The passwords are not same.'
				}
			}
		</script>


		<%@ include file="IncludeAccountFields.jsp"%>
		<form action="saveAccount">
			<input type="submit" name="SaveAccount" value="Save Account Information" id="save" />
		</form>
		<script language="JavaScript" type="text/javascript">
			// 快捷键响应
			// targetObj: 目标对象，如果满足快捷键条件，触发目标对象的click事件
			// ctrlKey: 是否按住了Ctrl组合键
			// shiftKey: 是否按住了Shift组合键
			// altKey: 是否按住了Alt组合键
			// keycode: 按键对应的数值
			function Hotkey(event, targetObj, ctrlKey,shiftKey, altKey, keycode){
				if (
						targetObj
						&& event.keyCode == keycode
				)
					targetObj.click();
			}

			function fnKeyup(event)
			{
				var b = document.getElementById("save");
				Hotkey(event, b, false, false, false, 13);
			}

			// 捕获系统的Keyup事件
			// 如果是Mozilla系列浏览器
			if (document.addEventListener)
				document.addEventListener("keyup",fnKeyup,true);
			else
				document.attachEvent("onkeyup",fnKeyup);

			//-->
		</script>
		<%--	</stripes:form>--%>
	</form>
	<%--	<stripes:link--%>
	<%--	beanclass="org.mybatis.jpetstore.web.actions.OrderActionBean"--%>
	<%--	event="listOrders">My Orders</stripes:link>--%>
	<a href="listOrders?username=${sessionScope.account.username}">My Orders</a>
</div>

<%@ include file="../common/IncludeBottom.jsp"%>
